<template>
  <view class="page-root">
    <view class="list-item" v-for="(item, index) in list" :key="index">
      <view class="list-title-wrap">
        <image class="rocket-icon" src="/static/rocket.png"></image>
        <view class="list-name ell1">{{ item.title }}</view>

        <!-- download-wrap 上加一个 disabled 类名即可显示禁用样式 -->
        <view class="download-wrap" @click="daoru(item)">
          <image class="download-icon" src="/static/download.png"></image>
          <view>下载</view>
        </view>
      </view>

      <view class="progress-wrap">
        <uv-line-progress :percentage="30" height="16px" inactiveColor="#6174AD" activeColor="#507afe"></uv-line-progress>
      </view>
    </view>
  </view>
</template>

<script>
import utils from "@/utils/util.js";
import Tabbar from "@/components/tabbar/tabbar.vue";
import uniPopup from "@/components/uni-popup/uni-popup.vue";
export default {
  components: {
    "view-tabbar": Tabbar,
    uniPopup,
  },
  data() {
    return {
      list: [], //我的报名
      total: 0, //总条数
      page: 1, //当前页数
      nodata: false, //是否有数据
      id: 0,
      lang: 0,
      data: {},
      data_s: {},
    };
  },
  onLoad(ops) {
    this.id = ops.id;
    this.getList();
  },
  onReachBottom() {
    this.page++;
    this.getList();
  },
  onShow() {
    let _this = this;
    if (uni.getStorageSync("lang")) {
      this.lang = uni.getStorageSync("lang");
    }
    if (this.lang == 1) {
      uni.setNavigationBarTitle({
        title: "series",
      });
    } else {
      uni.setNavigationBarTitle({
        title: "系列",
      });
    }
    this.data = uni.getStorageSync("dev_data");
    // if(this.$store.state.token) {
    // 	this.login = true;
    // 	this.$api.request('/api/user/center', {}, this.$store.state.token, function(res){
    // 		if(res.code == 1) {
    // 			_this.avatar = res.data.avatar;
    // 			_this.nickname = res.data.nickname;
    // 			_this.userType = res.data.guest_status;
    // 		}
    // 	});
    // }else {
    // 	this.login = false;
    // 	this.avatar = '../../../static/nologin.png';
    // 	this.nickname = '未登录';
    // }
  },
  methods: {
    save_confg() {
      let that = this;

      let BUFFERSIZE = 24;
      let i;
      let str_temp;
      let str = "";
      that.get_page0_information();
      that.get_page1_information();
      that.get_page2_information();
      that.get_page3_information();
      that.get_page4_information();
      that.get_page5_information();
      that.get_page6_information();

      // wx.getSavedFileList({
      //   success(res) {
      //     if (res.fileList.length > 0) {
      //       wx.removeSavedFile({
      //         filePath: res.fileList[0].filePath,
      //         complete(res) {
      //           console.log(res)
      //         }
      //       })
      //     }
      //   }
      // })

      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page0_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page1_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page2_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page3_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page4_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
        console.log(str_temp + that.data_s.page4_tx_message[i]);
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page5_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
        console.log(str_temp + that.data_s.page5_tx_message[i]);
      }
      for (i = 5; i < BUFFERSIZE - 2; i++) {
        str_temp = (that.data_s.page6_tx_message[i] & 0xff).toString() + "\r\n";
        str += str_temp;
      }

      var date = new Date();
      let str_date = utils.dateFtt(date);

      that.data_s.inifile_path = wx.env.USER_DATA_PATH + "/" + str_date + ".ini";
      const fs = wx.getFileSystemManager();

      fs.writeFile({
        filePath: that.data_s.inifile_path,
        data: str,
        encoding: "utf8",
        success(res) {
          console.log(222222222222, that.data_s.inifile_path);
          //可以分享的呢？
          uni.showModal({
            title: "是否确认分享",
            // content: '您的位置信息将用获取信息',
            success: (res) => {
              if (res.confirm) {
                wx.shareFileMessage({
                  filePath: that.data_s.inifile_path,
                  success() {
                    console.log("cg");
                  },
                  fail(res) {
                    console.log("分享失败", res);
                  },
                });
              }
            },
          });

          console.log(res);
        },
        fail(res) {
          console.error("erro", res);
        },
      });
    },
    get_page0_information: function () {
      let that = this;
      let temp;
      let tab = [0x05, 0x0a, 0x14, 0x1e, 0x28, 0, 0, 0, 0, 0, 0, 0, 0, 0];
      console.log(that.data_s, 7777777777777);

      that.data_s.page0_tx_message[5] = tab[that.data_s.pm_type_index];
      that.data_s.page0_tx_message[6] = that.data_s.voltage_level_index;
      that.data_s.page0_tx_message[6] |= (that.data_s.manufacturer_code_index << 4) & 0xff;
      temp = that.data_s.over_voltage_value * 10;
      that.data_s.page0_tx_message[7] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[8] = temp & 0xff;
      temp = that.data_s.under_voltage_value * 10;
      that.data_s.page0_tx_message[16] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[17] = temp & 0xff;

      temp = that.data_s.soft_under_voltage_value * 10;
      that.data_s.page0_tx_message[9] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[10] = temp & 0xff;

      temp = that.data_s.under_voltage_threshold_value * 10;
      that.data_s.page0_tx_message[11] = temp & 0xff;

      temp = that.data_s.bus_current_limit_value;
      that.data_s.page0_tx_message[12] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[13] = temp & 0xff;

      temp = that.data_s.phase_current_value;
      that.data_s.page0_tx_message[14] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[15] = temp & 0xff;

      temp = that.data_s.vol_calibration_value;
      that.data_s.page0_tx_message[18] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[19] = temp & 0xff;

      temp = that.data_s.cur_calibration_value;
      that.data_s.page0_tx_message[20] = (temp >> 8) & 0xff;
      that.data_s.page0_tx_message[21] = temp & 0xff;
    },
    get_page1_information: function () {
      let that = this;
      let temp;

      temp = that.data_s.sport_bus_current_limit;
      that.data_s.page1_tx_message[5] = (temp >> 8) & 0xff;
      that.data_s.page1_tx_message[6] = temp & 0xff;

      temp = that.data_s.low_speed_percent;
      that.data_s.page1_tx_message[7] = temp & 0xff;

      temp = that.data_s.mid_speed_percent;
      that.data_s.page1_tx_message[8] = temp & 0xff;

      temp = that.data_s.high_speed_percent;

      that.data_s.page1_tx_message[9] = temp & 0xff;

      temp = that.data.flux_weak_value;
      that.data_s.page1_tx_message[10] = (temp >> 8) & 0xff;
      that.data_s.page1_tx_message[11] = temp & 0xff;

      temp = that.data_s.phase_Kp;
      that.data_s.page1_tx_message[12] = (temp >> 8) & 0xff;
      that.data_s.page1_tx_message[13] = temp & 0xff;

      temp = that.data_s.phase_current_limit_value;
      that.data_s.page1_tx_message[14] = (temp >> 8) & 0xff;
      that.data_s.page1_tx_message[15] = temp & 0xff;

      temp = that.data_s.turtle_speed_pecent;
      that.data_s.page1_tx_message[17] = temp & 0xff;

      that.data_s.page1_tx_message[16] = 0;
      if (that.data_s.motor_type_selcet_value == 2) {
        that.data_s.page1_tx_message[16] |= 0x10;
      }
      if (that.data_s.soft_start_flag == true) {
        that.data_s.page1_tx_message[16] |= 0x80;
      }
      if (that.data_s.motor_noise_forbid_falg == true) {
        that.data_s.page1_tx_message[16] |= 0x40;
      }
      if (that.data_s.dot_switch_selcet_flag == 2) {
        that.data_s.page1_tx_message[16] |= 0x20;
      }
      if (that.data_s.turtle_speed_enable == true) {
        that.data_s.page1_tx_message[16] |= 0x01;
      }
      if (that.data_s.default_gear == 4) {
        that.data_s.page1_tx_message[16] |= 0x02;
      } else if (that.data_s.default_gear == 2) {
        that.data_s.page1_tx_message[16] |= 0x04;
      } else if (that.data_s.default_gear == 1) {
        that.data_s.page1_tx_message[16] |= 0x08;
      }
      that.data_s.page1_tx_message[18] = that.data_s.softstart_level_index;
      that.data_s.page1_tx_message[18]++;
      that.data_s.page1_tx_message[19] = that.data_s.sport_quit_time;
      that.data_s.page1_tx_message[20] = that.data_s.sport_recover_time;
      that.data_s.page1_tx_message[21] = that.data_s.flux_weak_compensate;
    },
    get_page2_information: function () {
      let that = this;
      let temp;
      temp = that.data_s.motor_shift_angle;
      that.data_s.page2_tx_message[5] = (temp >> 8) & 0xff;
      that.data_s.page2_tx_message[6] = temp & 0xff;

      temp = that.data_s.start_tempretrue_protect_value;
      that.data_s.page2_tx_message[7] = temp & 0xff;

      temp = that.data_s.over_temperetrue_protect_value;
      that.data_s.page2_tx_message[8] = temp & 0xff;

      temp = that.data.max_tempretrue_protect_value;
      that.data_s.page2_tx_message[9] = temp & 0xff;

      temp = that.data_s.tempretrue_fact;
      that.data_s.page2_tx_message[10] = (temp >> 8) & 0xff;
      that.data_s.page2_tx_message[11] = temp & 0xff;

      temp = that.data_s.adj_fact1;
      that.data_s.page2_tx_message[12] = (temp >> 8) & 0xff;
      that.data_s.page2_tx_message[13] = temp & 0xff;

      temp = that.data_s.adj_fact2;
      that.data_s.page2_tx_message[14] = (temp >> 8) & 0xff;
      that.data_s.page2_tx_message[15] = temp & 0xff;

      temp = that.data_s.reverse_speed_limit_percent;
      that.data_s.page2_tx_message[16] = temp & 0xff;

      that.data_s.page2_tx_message[17] = 0;
      // temp = page3.m_set_dr.GetCheck();

      if (that.data_s.set_motor_dir == 2) {
        that.data_s.page2_tx_message[17] |= 0x80;
      } /**/
      if (that.data_s.sport_auto_quit_enable == true) {
        that.data_s.page2_tx_message[17] |= 0x40;
      }
      if (that.data_s.exchange_hall_flag == true) {
        that.data_s.page2_tx_message[17] |= 0x20;
      }
      if (that.data_s.exchange_motor_phase_flag == true) {
        that.data_s.page2_tx_message[17] |= 0x10;
      }
      //temp = page1.m_park_enalbe.GetCheck();
      if (that.data_s.auto_park_enable == true) {
        that.data_s.page2_tx_message[17] |= 0x08;
      }
      that.data_s.page2_tx_message[18] = that.data_s.motor_pole_pair;
      that.data_s.page2_tx_message[19] = that.data_s.ebs_percent;
      that.data_s.page2_tx_message[20] = ((that.data_s.software_vision + 0.009999) * 100) & 0xff;
      that.data_s.page2_tx_message[21] = ((that.data_s.m_hardware_vision + 0.009999) * 100) & 0xff;
    },
    get_page3_information: function () {
      let that = this;
      let temp;
      that.data_s.page3_tx_message[5] = 0;
      if (that.data_s.aux_move_enable_flag == true) {
        that.data_s.page3_tx_message[5] |= 0x01;
      }
      if (that.data_s.max_speed_limit_enable == true) {
        that.data_s.page3_tx_message[5] |= 0x02;
      }
      if (that.data_s.output_type_selcet_value == 1) {
        that.data_s.page3_tx_message[5] |= 0x04;
      }
      if (that.data_s.cruise_enable_falg == true) {
        that.data_s.page3_tx_message[5] |= 0x08;
      }
      if (that.data_s.double_voltage_enable == true) {
        that.data_s.page3_tx_message[5] |= 0x10;
      }
      if (that.data_s.double_voltage_value == 2) {
        that.data_s.page3_tx_message[5] |= 0x20;
      }
      if (that.data_s.safe_start_enable_flag == true) {
        that.data_s.page3_tx_message[5] |= 0x40;
      }
      temp = (that.data_s.aux_speed_limit_percent * 32768) / 100;
      that.data_s.page3_tx_message[6] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[7] = temp & 0xff;

      temp = that.data_s.aux_torque_limit_value;
      that.data_s.page3_tx_message[8] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[9] = temp & 0xff;

      temp = that.data_s.max_speed_limit_value;
      that.data_s.page3_tx_message[10] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[11] = temp & 0xff;

      temp = that.data_s.low_speed_limit_current_percet;
      that.data_s.page3_tx_message[12] = temp & 0xff;

      temp = that.data_s.mid_speed_limit_current_percet;
      that.data_s.page3_tx_message[13] = temp & 0xff;

      temp = that.data_s.over_module_percent;
      that.data_s.page3_tx_message[14] = temp & 0xff;

      temp = that.data_s.phase_Ki;
      that.data_s.page3_tx_message[15] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[16] = temp & 0xff;

      temp = that.data_s.rated_phase_current_value;
      that.data_s.page3_tx_message[17] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[18] = temp & 0xff;

      temp = that.data_s.rated_phase_current_limit_time;
      that.data_s.page3_tx_message[19] = (temp >> 8) & 0xff;
      that.data_s.page3_tx_message[20] = temp & 0xff;

      that.data_s.page3_tx_message[21] = that.data_s.flux_weak_calibration_value;
    },
    get_page4_information: function () {
      let that = this;
      let temp;
      let i = 0;

      temp = that.data_s.function_select_index0;
      temp |= (that.data_s.function_select_radiobox0 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox0 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox0 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index1;
      temp |= (that.data_s.function_select_radiobox1 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox1 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox1 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index2;
      temp |= (that.data_s.function_select_radiobox2 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox2 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox2 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index3;
      temp |= (that.data_s.function_select_radiobox3 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox3 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox3 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index4;
      temp |= (that.data_s.function_select_radiobox4 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox4 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox4 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index5;
      temp |= (that.data_s.function_select_radiobox5 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox5 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox5 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index6;
      temp |= (that.data_s.function_select_radiobox6 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox6 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox6 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index7;
      temp |= (that.data_s.function_select_radiobox7 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox7 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox7 & 0x03) << 7;
      that.data_s.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
      that.data_s.page4_tx_message[6 + i * 2] = temp & 0xff;
      that.data_s.page4_tx_message[21] = that.data_s.flux_weak_calibration_value;
    },
    get_page5_information: function () {
      let that = this;
      let temp;
      let i = 8;
      temp = that.data_s.function_select_index8;
      temp |= (that.data_s.function_select_radiobox8 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox8 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox8 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index9;
      temp |= (that.data_s.function_select_radiobox9 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox9 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox9 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index10;
      temp |= (that.data_s.function_select_radiobox10 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox10 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox10 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index11;
      temp |= (that.data_s.function_select_radiobox11 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox11 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox11 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index12;
      temp |= (that.data_s.function_select_radiobox12 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox12 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox12 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index13;
      temp |= (that.data_s.function_select_radiobox13 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox13 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox13 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index14;
      temp |= (that.data_s.function_select_radiobox14 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox14 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox14 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
      i++;
      temp = that.data_s.function_select_index15;
      temp |= (that.data_s.function_select_radiobox15 >> 1) << 9;
      temp |= (that.data_s.function_select_checkbox15 & 0x04) << 9;
      temp |= (that.data_s.function_select_checkbox15 & 0x03) << 7;
      that.data_s.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
      that.data_s.page5_tx_message[6 + (i - 8) * 2] = temp & 0xff;
    },
    get_page6_information: function () {
      let that = this;

      that.data_s.page6_tx_message[5] = ((that.data_s.footplat_start_value * 255) / 5.5) & 0xff;
      that.data_s.page6_tx_message[6] = ((that.data_s.footplat_end_value * 255) / 5.5) & 0xff;
      that.data_s.page6_tx_message[7] = ((that.data_s.footplat_low_protect_value * 255) / 5.5) & 0xff;
      that.data_s.page6_tx_message[8] = ((that.data_s.footplat_high_protect_value * 255) / 5.5) & 0xff;

      that.data_s.page6_tx_message[9] = that.data_s.sink_ratio & 0xff;
      that.data_s.page6_tx_message[10] = that.data_s.rise_ratio & 0xff;
      that.data_s.page6_tx_message[11] = (that.data_s.start_torque >> 8) & 0xff;
      that.data_s.page6_tx_message[12] = that.data_s.start_torque & 0xff;
      that.data_s.page6_tx_message[13] = (that.data_s.combine_torque >> 8) & 0xff;
      that.data_s.page6_tx_message[14] = that.data_s.combine_torque & 0xff;
    },
    deldata(item) {
      let that = this;
      uni.showModal({
        title: "是否确认删除",
        // content: '您的位置信息将用获取信息',
        success: (res) => {
          if (res.confirm) {
            that.$api.request("/api/user/delconfig", { id: item.id }, that.$store.state.token, function (res) {
              if (res.code == 1) {
                that.page = 1;
                that.list = [];
                that.total = 0;
                that.getList();
              }
            });
          }
        },
      });
    },
    share_data(item) {
      let that = this;

      that.data_s.json_arr = item.json_arr;

      that.data_s.json_arr.soft_start_flag = that.data_s.json_arr.soft_start_flag == 1 ? true : false;

      that.data_s.json_arr.soft_start_flag = that.data_s.json_arr.soft_start_flag == 1 ? true : false;
      that.data_s.json_arr.max_speed_limit_enable = that.data_s.json_arr.max_speed_limit_enable == 1 ? true : false;
      that.data_s.json_arr.auto_park_enable = that.data_s.json_arr.auto_park_enable == 1 ? true : false;
      that.data_s.json_arr.turtle_speed_enable = that.data_s.json_arr.turtle_speed_enable == 1 ? true : false;
      that.data_s.json_arr.sport_auto_quit_enable = that.data_s.json_arr.sport_auto_quit_enable == 1 ? true : false;

      that.data_s.json_arr.exchange_hall_flag = that.data_s.json_arr.exchange_hall_flag == 1 ? true : false;
      that.data_s.json_arr.exchange_motor_phase_flag = that.data_s.json_arr.exchange_motor_phase_flag == 1 ? true : false;

      that.data_s.json_arr.aux_move_enable_flag = that.data_s.json_arr.aux_move_enable_flag == 1 ? true : false;
      that.data_s.json_arr.double_voltage_enable = that.data_s.json_arr.double_voltage_enable == 1 ? true : false;

      that.data_s.json_arr.motor_noise_forbid_falg = that.data_s.json_arr.motor_noise_forbid_falg == 1 ? true : false;
      that.data_s.json_arr.safe_start_enable_flag = that.data_s.json_arr.safe_start_enable_flag == 1 ? true : false;
      that.data_s.json_arr.cruise_enable_flag = that.data_s.json_arr.cruise_enable_flag == 1 ? true : false;

      that.data_s.json_arr.set_motor_dir = Number(that.data_s.json_arr.set_motor_dir);
      that.data_s.json_arr.motor_type_selcet_value = Number(that.data_s.json_arr.motor_type_selcet_value);
      that.data_s.json_arr.output_type_selcet_value = Number(that.data_s.json_arr.output_type_selcet_value);
      that.data_s.json_arr.double_voltage_value = Number(that.data_s.json_arr.double_voltage_value);

      that.data_s.json_arr.dot_switch_selcet_flag = Number(that.data_s.json_arr.dot_switch_selcet_flag);
      that.data_s.json_arr.default_gear = Number(that.data_s.json_arr.default_gear);

      that.data_s.json_arr.function_select_checkbox0 = Number(that.data_s.json_arr.function_select_checkbox0);
      that.data_s.json_arr.function_select_checkbox1 = Number(that.data_s.json_arr.function_select_checkbox1);
      that.data_s.json_arr.function_select_checkbox2 = Number(that.data_s.json_arr.function_select_checkbox2);
      that.data_s.json_arr.function_select_checkbox3 = Number(that.data_s.json_arr.function_select_checkbox3);
      that.data_s.json_arr.function_select_checkbox4 = Number(that.data_s.json_arr.function_select_checkbox4);
      that.data_s.json_arr.function_select_checkbox5 = Number(that.data_s.json_arr.function_select_checkbox5);
      that.data_s.json_arr.function_select_checkbox6 = Number(that.data_s.json_arr.function_select_checkbox6);
      that.data_s.json_arr.function_select_checkbox7 = Number(that.data_s.json_arr.function_select_checkbox7);
      that.data_s.json_arr.function_select_checkbox8 = Number(that.data_s.json_arr.function_select_checkbox8);
      that.data_s.json_arr.function_select_checkbox9 = Number(that.data_s.json_arr.function_select_checkbox9);
      that.data_s.json_arr.function_select_checkbox10 = Number(that.data_s.json_arr.function_select_checkbox10);
      that.data_s.json_arr.function_select_checkbox11 = Number(that.data_s.json_arr.function_select_checkbox11);
      that.data_s.json_arr.function_select_checkbox12 = Number(that.data_s.json_arr.function_select_checkbox12);
      that.data_s.json_arr.function_select_checkbox13 = Number(that.data_s.json_arr.function_select_checkbox13);
      that.data_s.json_arr.function_select_checkbox14 = Number(that.data_s.json_arr.function_select_checkbox14);
      that.data_s.json_arr.function_select_checkbox15 = Number(that.data_s.json_arr.function_select_checkbox15);

      that.data_s.json_arr.function_select_index0 = Number(that.data_s.json_arr.function_select_index0);
      that.data_s.json_arr.function_select_index1 = Number(that.data_s.json_arr.function_select_index1);
      that.data_s.json_arr.function_select_index2 = Number(that.data_s.json_arr.function_select_index2);
      that.data_s.json_arr.function_select_index3 = Number(that.data_s.json_arr.function_select_index3);
      that.data_s.json_arr.function_select_index4 = Number(that.data_s.json_arr.function_select_index4);
      that.data_s.json_arr.function_select_index5 = Number(that.data_s.json_arr.function_select_index5);
      that.data_s.json_arr.function_select_index6 = Number(that.data_s.json_arr.function_select_index6);
      that.data_s.json_arr.function_select_index7 = Number(that.data_s.json_arr.function_select_index7);
      that.data_s.json_arr.function_select_index8 = Number(that.data_s.json_arr.function_select_index8);
      that.data_s.json_arr.function_select_index9 = Number(that.data_s.json_arr.function_select_index9);
      that.data_s.json_arr.function_select_index10 = Number(that.data_s.json_arr.function_select_index10);
      that.data_s.json_arr.function_select_index11 = Number(that.data_s.json_arr.function_select_index11);
      that.data_s.json_arr.function_select_index12 = Number(that.data_s.json_arr.function_select_index12);
      that.data_s.json_arr.function_select_index13 = Number(that.data_s.json_arr.function_select_index13);
      that.data_s.json_arr.function_select_index14 = Number(that.data_s.json_arr.function_select_index14);
      that.data_s.json_arr.function_select_index15 = Number(that.data_s.json_arr.function_select_index15);

      that.data_s.json_arr.function_select_radiobox0 = Number(that.data_s.json_arr.function_select_radiobox0);
      that.data_s.json_arr.function_select_radiobox1 = Number(that.data_s.json_arr.function_select_radiobox1);
      that.data_s.json_arr.function_select_radiobox2 = Number(that.data_s.json_arr.function_select_radiobox2);
      that.data_s.json_arr.function_select_radiobox3 = Number(that.data_s.json_arr.function_select_radiobox3);
      that.data_s.json_arr.function_select_radiobox4 = Number(that.data_s.json_arr.function_select_radiobox4);
      that.data_s.json_arr.function_select_radiobox5 = Number(that.data_s.json_arr.function_select_radiobox5);
      that.data_s.json_arr.function_select_radiobox6 = Number(that.data_s.json_arr.function_select_radiobox6);
      that.data_s.json_arr.function_select_radiobox7 = Number(that.data_s.json_arr.function_select_radiobox7);
      that.data_s.json_arr.function_select_radiobox8 = Number(that.data_s.json_arr.function_select_radiobox8);
      that.data_s.json_arr.function_select_radiobox9 = Number(that.data_s.json_arr.function_select_radiobox9);
      that.data_s.json_arr.function_select_radiobox10 = Number(that.data_s.json_arr.function_select_radiobox10);
      that.data_s.json_arr.function_select_radiobox11 = Number(that.data_s.json_arr.function_select_radiobox11);
      that.data_s.json_arr.function_select_radiobox12 = Number(that.data_s.json_arr.function_select_radiobox12);
      that.data_s.json_arr.function_select_radiobox13 = Number(that.data_s.json_arr.function_select_radiobox13);
      that.data_s.json_arr.function_select_radiobox14 = Number(that.data_s.json_arr.function_select_radiobox14);
      that.data_s.json_arr.function_select_radiobox15 = Number(that.data_s.json_arr.function_select_radiobox15);

      let s = that.data_s;
      that.data_s = {};
      that.data_s = s.json_arr;

      //需要先把当前配置 生成文件
      that.save_confg();
    },
    share_config: function () {
      let that = this;
      if (that.data.param_read_success_flag == true) {
        wx.shareFileMessage({
          filePath: that.data.inifile_path,
          success() {
            console.log("cg");
          },
          fail: console.error,
        });
      }
    },
    daoru(item) {
      console.log(item, 777777777);
      let that = this;
      //that.daoru_dea
      uni.showModal({
        title: "是否确认导入",
        // content: '您的位置信息将用获取信息',
        success: (res) => {
          if (res.confirm) {
            that.daoru_dea(item);
          }
        },
      });
    },
    daoru_dea(item) {
      let that = this;
      let inifile_path;
      uni.request({
        url: item.file,
        method: "GET",
        data: {
          username: "test",
          password: "123456",
        },
        success: function (res) {
          that.download(res.data);
        },
      });
    },
    download(data) {
      console.log("data", data);

      //1次20个？  1次 2000个
      let zuhe = [];
      let new_str = [];

      new_str = [];
      console.log("data.length", data.length);
      for (let i = 0; data.length; i++) {
        new_str.push(data.substring(i, i + 1));
        if (new_str.length % 20 == 0) {
          let temp = this.$util.CRC16Modbus(new_str);
          console.log("temp" + i, temp);

          new_str = [];
        }
        if (new_str.length % 100 == 0) {
          zuhe.push(new_str);
        }
      }
      // console.log("zuhe",zuhe)
    },
    getList() {
      let _this = this;
      this.$api.request(
        "/api/index/getxilie_childen",
        {
          page: this.page,
          id: this.id,
        },
        this.$store.state.token,
        function (res) {
          if (res.code == 1) {
            if (_this.page == 1) {
              _this.list = res.data.data;
            } else {
              _this.list = _this.list.concat(res.data.data);
            }
            _this.total = res.data.total_item_count;
            if (_this.list.length > 0) {
              _this.nodata = false;
            } else {
              _this.nodata = true;
            }
          }
        }
      );
    },
    goDetail(url) {
      uni.navigateTo({
        url: url,
      });
    },
  },
};
</script>

<style>
page {
  background: #19253e;
}
</style>

<style lang="scss" scoped>
.page-root {
  padding-bottom: 20rpx;
  color: #fff;
}
.list-item {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10rpx;
  padding: 20rpx;
  margin: 20rpx 30rpx 0;
  font-style: 32rpx;
  .list-title-wrap {
    display: flex;
    align-items: center;
    .rocket-icon {
      width: 32rpx;
      height: 32rpx;
      margin-right: 10rpx;
    }
    .list-name {
      flex: 1;
    }
    .download-wrap {
      width: 112rpx;
      height: 48rpx;
      background: #4f7afd;
      border-radius: 10rpx;
      margin-left: 20rpx;
      color: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      &.disabled {
        background: #c0c9e1;
      }
    }
    .download-icon {
      width: 24rpx;
      height: 24rpx;
      margin-right: 10rpx;
    }
  }
  .progress-wrap {
    margin-top: 30rpx;
  }
}
</style>
